﻿using System;
using System.Collections.Generic;
using DevExpress.Xpo;
using System.Text;

namespace BusinessObjects
{
    public class TestProfile : XPObject
    {
        public TestProfile()
            : base()
        {
            // This constructor is used when an object is loaded from a persistent storage.
            // Do not place any code here.
        }

        public TestProfile(Session session)
            : base(session)
        {
            // This constructor is used when an object is loaded from a persistent storage.
            // Do not place any code here.
        }

        public override void AfterConstruction()
        {
            base.AfterConstruction();
            // Place here your initialization code.
        }

        //Fields
        TestUser fUser = null;
        public TestUser User
        {
            get { return fUser; }
            set
            {
                if (fUser == value)
                    return;

                TestUser prevOwner = fUser;
                fUser = value;

                if (IsLoading) return;

                if (prevOwner != null && prevOwner.Profile == this)
                    prevOwner.Profile = null;

                if (fUser != null)
                    fUser.Profile = this;
                OnChanged("User");
            }
        }

        string fEmail;
        [Size(50)]
        public string Email
        {
            get { return fEmail; }
            set { SetPropertyValue<string>("Email", ref fEmail, value); }
        }
    }
}
